Micron Document
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| SparkN0de-git | SparkN0de |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Commit 0bf7fce688757a71e7581456273720477c9203eb


Parents : 314febe
Author : Mark Qvist <mark@unsigned.io>
Date : 2025-11-24T19:47:07+01:00

Fixed display resolution getter on rotated displays

Changes

1 files changed, 19 insertions(+), 4 deletions(-)

M sbapp/main.py +19 -4

Diff

diff --git a/sbapp/main.py b/sbapp/main.py
index 0b4c1638..1e0b5cc8 100644
--- a/sbapp/main.py
+++ b/sbapp/main.py
@@ -49,11 +49,26 @@ def get_display_res():
else:
try:
import subprocess
- cmd_xrandr = subprocess.Popen(['xrandr'], stdout=subprocess.PIPE)
- cmd_grep = subprocess.Popen(['grep', '*'], stdin=cmd_xrandr.stdout, stdout=subprocess.PIPE)
+ # Try to get connected and primary display
+ cmd_xrandr = subprocess.Popen(["xrandr"], stdout=subprocess.PIPE)
+ cmd_grep = subprocess.Popen(["grep", " connected primary"], stdin=cmd_xrandr.stdout, stdout=subprocess.PIPE)
cmd_xrandr.stdout.close(); res_bytes, _ = cmd_grep.communicate()
- resolution = res_bytes.split()[0]
- width, height = resolution.split(b'x')
+ if not (len(res_bytes) > 25 and b"x" in res_bytes):
+ # Try to get connected display
+ cmd_xrandr = subprocess.Popen(["xrandr"], stdout=subprocess.PIPE)
+ cmd_grep = subprocess.Popen(["grep", " connected"], stdin=cmd_xrandr.stdout, stdout=subprocess.PIPE)
+ cmd_xrandr.stdout.close(); res_bytes, _ = cmd_grep.communicate()
+
+ resolution_es = res_bytes.split()
+ for e in resolution_es:
+ if b"x" in e:
+ if b"+" in e: e = e.split(b"+")[0]
+ cs = e.split(b"x")
+ if len(cs) == 2:
+ resolution = e
+ break
+
+ width, height = resolution.split(b"x")
app_ui_dsp_width = int(width)
app_ui_dsp_height = int(height)
return app_ui_dsp_width, app_ui_dsp_height


──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────